package com.beijiteshop.shop.utils

import com.beijiteshop.shop.model.api.response.ProductBean
import com.beijiteshop.shop.model.api.response.ProductDetailBean

/**
 * @Author LiaoZhongKai
 * @Date 2021/3/26 16:16
 * @Description
 */
object SpecColorUtil {

    fun checkIsSelectSpecOrColor(product: ProductBean?,productDetailBean: ProductDetailBean?): Boolean{
        if (product == null){
            return false
        }

        if (productDetailBean == null){
            return false
        }

        val detailBean: ProductDetailBean = productDetailBean

        if (!detailBean.specifications.isNullOrEmpty() && !detailBean.colors.isNullOrEmpty() && (product.spec == null || product.color == null)){
            return false
        }

        if (detailBean.specifications.isNullOrEmpty() && detailBean.colors.isNullOrEmpty() && detailBean.specification == null){
            return false
        }

        if (!detailBean.specifications.isNullOrEmpty() && product.spec == null){
            return false
        }

        if (!detailBean.colors.isNullOrEmpty() && product.color == null){
            return false
        }

        return true
    }
}